package lab03.Test03;

import java.lang.String;
import lab02.Test10.BeijingPeople;

import java.io.*;

public class test {
    public static void main(String[] args) {
        String path="D://test.txt";
        byte b[]="Beijing 欢迎你！".getBytes();
        FileOutputStream fileOutputStream=null;
        try {
             fileOutputStream=new FileOutputStream(path);
            fileOutputStream.write(b);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        FileInputStream fileInputStream=null;
        try {
             fileInputStream=new FileInputStream(path);
            int current;
            String s="";
            while ((current=fileInputStream.read())!=-1) {
                //current+=current;
                s+=(char)current;
                //System.out.println( current);
            }
            System.out.println(  new String(s.getBytes("ISO-8859-1"),"utf-8"));
           // System.out.println("我的学号是：");
//            byte[]date=new byte[456];
//            int count=System.in.read(date);
//            fileInputStream.read();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        FileWriter fileWriter=null;
        try {
             fileWriter=new FileWriter(path);
            fileWriter.write("我的学号是：你自己的学号");
        } catch (IOException e) {
            e.printStackTrace();
        }

        finally {
            try {
                fileWriter.close();
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
